<template>
  <div class="cemeteryDead  h100" v-loading="loading">
    <div class="pageContent">
      <el-form
        :model="ruleForm"
        :inline="true"
        ref="ruleForm"
        label-width="80px"
        class="PageItem margintop20"
      >
        <el-row :gutter="20" class="fileSearch">
          <el-col :span="6">
            <el-form-item label="逝者姓名:" prop="deadName">
              <el-input v-model="ruleForm.deadName" clearable></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item>
              <el-button
                type="primary"
                size="medium"
                @click="onSubmit(1)"
                icon="el-icon-search"
              >
                查询
              </el-button>
              <el-button type="primary" size="medium" icon="el-icon-search">
                导入
              </el-button>
              <el-button
                icon="el-icon-refresh"
                size="medium"
                @click="resetQuery"
                >重置</el-button
              >
            </el-form-item>
          </el-col>
        </el-row>
        <el-table
          :data="tableData"
          border
          :header-cell-style="{
            background: 'rgb(246,247,251)',
            color: '#606266'
          }"
          stripe
          class="defaultTableHeight"
        >
          <el-table-column type="index" label="编号" width="50">
          </el-table-column>
          <el-table-column
            prop="deadName"
            align="center"
            label="逝者姓名"
          ></el-table-column>
          <el-table-column
            prop="deadGender"
            align="center"
            label="姓别"
          ></el-table-column>
          <el-table-column
            prop="cremationDate"
            align="center"
            label="火化日期"
          ></el-table-column>
          <el-table-column
            prop="moveCreate"
            align="center"
            label="迁入日期"
          ></el-table-column>
          <el-table-column prop="businessType" align="center" label="骨灰状态">
            <template slot-scope="scope">
              {{ scope.row.businessType === "gm_mx_in" ? "安葬" : "寄存" }}
            </template>
          </el-table-column>
          <el-table-column
            prop="businessCode"
            align="center"
            label="骨灰追溯编号"
          ></el-table-column>
          <el-table-column
            prop="certificateNo"
            align="center"
            label="证件号"
          ></el-table-column>
          <el-table-column
            prop="gwPositionName"
            align="center"
            label="格位节点"
          ></el-table-column>
        </el-table>
        <p style="text-align: right;">
          <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="pager.currentPage"
            :page-size="pager.pageSize"
            :page-sizes="[10, 20, 30, 50]"
            background
            layout="total,sizes,prev, pager, next, jumper"
            :total="pager.total"
          >
          </el-pagination>
        </p>
      </el-form>
    </div>
  </div>
</template>

<script>
import * as Type from "@/api/cemeteryDeadManage";
export default {
  name: "UserRecord",
  data() {
    return {
      parksOptions: [],
      loading: false,
      type: [],
      ruleForm: {
        deadName: ""
      },
      pager: {
        pageSize: 20,
        total: 1,
        currentPage: 1
      },
      tableData: [],
      tableHeight: 0
    };
  },
  components: {},
  //载入按钮
  mounted() {
    // this.onSubmit();
  },
  //注销window.onresize事件
  destroyed() {},
  methods: {
    //表单提交
    onSubmit(val) {
      if (val) {
        this.pager.currentPage = 1;
      }
      this.loading = true;
      let postData = {
        deadName: this.ruleForm.deadName,
        businessType: this.ruleForm.businessType,
        businessCode: this.ruleForm.businessCode,
        certificateNo: this.ruleForm.certificateNo,
        mxCaseNo: this.ruleForm.mxCaseNo,
        gwCaseNo: this.ruleForm.gwCaseNo,
        outFlag: this.ruleForm.outFlag,
        pageSize: this.pager.pageSize,
        currentPage: this.pager.currentPage,
        saveFirstLevel: this.ruleForm.saveFirstLevel,
        "orderField	": "", //排序字段
        orderType: "" //排序顺序
      };

      //查询接口
      //console.log(postData)
      Type["getDeadList"](postData)
        .then(response => {
          const { data } = response;
          if (!data) {
            this.loading = false;
            this.$message("数据读取失败");
            return;
          }
          this.tableData = data.list;
          data.pager.pageSize = this.pager.pageSize;
          this.pager = data.pager;
          this.loading = false;
          //数据读取成功
        })
        .catch(error => {
          this.$message(error);
          this.loading = false;
          this.tableData = [];
        });
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.$refs["ruleForm"].resetFields();
      this.onSubmit();
    },
    // 初始页currentPage、初始每页数据数pagesize和数据data
    handleSizeChange: function(size) {
      this.pager.pageSize = size;
      this.onSubmit();
    },
    handleCurrentChange: function(currentPage) {
      this.pager.currentPage = currentPage;
      this.onSubmit(); //点击第几页
    }
  }
};
</script>

<style scoped>
.el_img {
  cursor: pointer;
}
.w150 {
  width: 150px;
}
.excel-upload-input {
  display: none;
  z-index: -9999;
}
</style>
